package com.prs.crm.action.sys;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;

import com.prs.crm.domain.sys.DefaultAccountSet;
import com.prs.crm.service.sys.DefaultAccountSetService;

public class DefaultAccountSetAction extends BaseAction{

	
	private static final long serialVersionUID = 1L;
	private DefaultAccountSet defaultAccountSet;
	private DefaultAccountSetService defaultAccountSetService;
	private String serCode;
	public String getSerCode() {
		return serCode;
	}
	public void setSerCode(String serCode) {
		this.serCode = serCode;
	}
	public DefaultAccountSet getDefaultAccountSet() {
		return defaultAccountSet;
	}
	public void setDefaultAccountSet(DefaultAccountSet defaultAccountSet) {
		this.defaultAccountSet = defaultAccountSet;
	}
	public DefaultAccountSetService getDefaultAccountSetService() {
		return defaultAccountSetService;
	}
	public void setDefaultAccountSetService(
			DefaultAccountSetService defaultAccountSetService) {
		this.defaultAccountSetService = defaultAccountSetService;
	}
	@Action("editDefaultAccountSet")
	public String editDefaultAccountSet(){
		this.defaultAccountSet=this.getDefaultAccountSetService().getDefaultAccountSet(serCode);
		return SUCCESS;
	}
	@Action(value="saveDefaultAccountSet",results={
			@Result(name="success",type="redirect",location="editDefaultAccountSet?serCode=${defaultAccountSet.getType()}"),
			@Result(name="error",type="chain",location="editDefaultAccountSet?serCode=${defaultAccountSet.getType()}")
	})
	public String saveDefaultAccountSet(){
		DefaultAccountSet account=this.getDefaultAccountSetService().getDefaultAccountSet("ds01");
		if (account==null) {
			account=new DefaultAccountSet();
			account.setType("ds01");
			account.setSendAllUser(defaultAccountSet.getSendAllUser());
			account.setLeadMail(defaultAccountSet.getLeadMail());
			account.setUpdateSignature(defaultAccountSet.getUpdateSignature());
			account.setLimitPersonNum(defaultAccountSet.getLimitPersonNum());
			account.setPersonNum(defaultAccountSet.getPersonNum());
			account.setUseIpLogin(defaultAccountSet.getUseIpLogin());
			account.setIp1(defaultAccountSet.getIp1());
			account.setIp2(defaultAccountSet.getIp2());
			account.setIp3(defaultAccountSet.getIp3());
			account.setIp4(defaultAccountSet.getIp4());
			account.setNwApprove(defaultAccountSet.getNwApprove());
			account.setUseUsb(defaultAccountSet.getUseUsb());
			account.setUseIpPersonal(defaultAccountSet.getUseIpPersonal());
			account.setFileUseSpace(defaultAccountSet.getFileUseSpace());
			account.setEmailUseSpace(defaultAccountSet.getEmailUseSpace());
			account.setUploadMaxVolume(defaultAccountSet.getUploadMaxVolume());
			account.setOaHelper(defaultAccountSet.getOaHelper());
			account.setRefreshRate(defaultAccountSet.getRefreshRate());
			account.setNews(defaultAccountSet.getNews());
			account.setInform(defaultAccountSet.getInform());
			account.setNotice(defaultAccountSet.getNotice());
			account.setShortMessage(defaultAccountSet.getShortMessage());
			account.setFile(defaultAccountSet.getFile());
			account.setUpdateFile(defaultAccountSet.getUpdateFile());
			account.setSchedule(defaultAccountSet.getSchedule());
			account.setTask(defaultAccountSet.getTask());
			account.setAppMessage(defaultAccountSet.getAppMessage());
			account.setGongwen(defaultAccountSet.getGongwen());
			account.setUpdataUserAll(defaultAccountSet.getUpdataUserAll());
			this.getDefaultAccountSetService().save(account);
		}else{
			this.getDefaultAccountSetService().submit(account);
		}
		defaultAccountSet=account;
		return SUCCESS;
	}
}
